package top.lunarye.handler.handler;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * channel -> Handler 控制器
 * @author lunar
 * @since 2022-07-19
 */
@Component
public class HandlerHolder {
    private final Map<Integer, Handler> handlerMap = new HashMap<>(128);

    public void putHandler(Integer channelCode, Handler handler) {
        handlerMap.put(channelCode, handler);
    }

    public Handler route(Integer channelCode) {
        return handlerMap.get(channelCode);
    }
}
